<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>管理员注册</title>
    <link rel="stylesheet" th:href="@{/src/css/layui.css}">
</head>
<body>
<form class="layui-form" style="width:80%;" id="arf">
    <div class="layui-form-item">
        <label class="layui-form-label">重置密码</label>
        <div class="layui-input-block">
            <input type="password"class="layui-input userName" lay-verify="required"
                   placeholder="请输入密码" name="passWord">
            <label>（<span style="color: red">*</span>6-16位字母、数字组成</label>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">确认密码</label>
        <div class="layui-input-block">
            <input type="password"class="layui-input userName" lay-verify="required"
                   placeholder="请再次输入密码" name="rePassWord">
        </div>
    </div>
    <div class="layui-form-item"   style="width: 100px;margin-right: 0px">
        <div class="layui-input-block">
        <a type="button" class="layui-btn getNode">获取验证码</a>
        </div>
    </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">验证码</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input userName" lay-verify="required"
                   placeholder="请输入验证码" name="phoneCode">
        </div>
    </div>
    <div class="layui-form-item" style="margin: auto;text-align: center">
        <div class="layui-input-block" style="margin-left: 80px;text-align: center">
            <button class="layui-btn layui-btn-danger" lay-submit="" lay-filter="register" style="width: 100%;border-radius: 5px">立即重置</button>
        </div>
    </div>
</form>
<script th:src="@{/src/layui.js}"></script>
<script th:src="@{/src/js/jquery-1.9.1.min.js}"></script>
<script>

        layui.use(['form','jquery','layer'],function () {
            var form = layui.form,
                $ = layui.jquery,
                layer = layui.layer;
            $(".getNode").click(function () {
                $.ajax({
                    url:'/admin/node',
                    type:'get',
                    dataType:'json',
                    success:function (re) {
                        if (re.code == 200){
                            layer.msg(re.message,{icon:1});
                        } else {
                            layer.msg(re.message,{icon:5});
                        }
                    }
                });
            });
            form.on('submit(register)',function (data) {
               $.ajax({
                   url:'/admin/changePwd',
                   data:data.field,
                   type:'post',
                   dataType:'json',
                   success:function (result) {
                       if(result.code == 200){
                           layer.msg(result.message,{icon:1},function () {
                               parent.location.href='/exit';
                           })
                       }else{
                           layer.msg(result.message,{icon:5});
                       }
                   }
               })

               return false;
            })
        })
</script>
</body>
</html>